package com.netvitesse.nvconnect.test

import geb.spock.GebSpec
import geb.Page
import spock.lang.*


class GebTestWithSpock extends GebSpec {

	

	def setup() {
		baseUrl = "http://192.168.16.30:8080"
		go()
	}

//	def "missing methods are invoked on the driver instance"() {
//		// This also verifies that the driver instance is instantiated correctly
//		when:
//		go("/")
//		then:
//		notThrown(Exception)
//	}

//	def "Verifying the login process"() {
//		given: "I'm at the login page"
//		to LoginPage
//		
//		when: "I enter the correct username and password"
//		field_user.value("admin")
//		field_psw.value("admin")
//		loginbtn.click()
//		
//		then: "Should be on some where else"
//		$().text().contains("Welcome, administrator")		
//	}	

	
	
	
//**********95%Finish Case User Create*******	
		
//	def "User Create"() {
//		setup: "Login the page"
//		def msg
//		def loginStr = "d.trump"
//		def pswStr = "urhired"
//		
//		to LoginPage
//		user.value("admin")
//		psw.value("admin")
//		loginbtn.click(NvConnectManagerPage)
//		clickLink("Administration"," ").link.click()
//		
//		when: "I want to create a new user"
//		clickLink("Users"," ").link.click()
//		clickLink("New User","innermenu").link.click(NewUserPage)
//		login.value(loginStr)
//		fullName.value("Donald Trump")
//		password.value(pswStr)
//		description.value("Become the new CEO")
//		button("ROLE_USER").button.click()
//		button("ROLE_ADMIN").button.click()
//		button("btnSubmit").button.click()
//		and: "If successfully created, should should the following message"
//		msg = "User "+loginStr+" created"
//		
//		then: "The new user should be properly created"		
//		$().text().contains(msg)
//		
//		when: "I sign out and sign in with the newly created account"
//		to NvConnectManagerPage
//		clickLink("Logout"," ").link.click(LoginPage)
//		user.value(loginStr)
//		psw.value(pswStr)
//		loginbtn.click(NvConnectManagerPage)
//		
//		then: "Should login successfully"
//		$().text().contains("Welcome, "+loginStr)
//		
//		when: "I want to delete the user that I just created"
//		clickLink("Users"," ").link.click()
//		$("div#usersList_length").usersList_length = 100	
//		$("td", text:loginStr).previous().find("input#deleteTitle").click()
//				
//		then: "Not finished yet"
//		$().text().contains("Welcome")
//	}
//****************************************************
	

	def "SMTP configuration"() {
		
		setup: "Login the page"
		

		to LoginPage
		user.value("admin")
		psw.value("admin")
		loginbtn.click(NvConnectManagerPage)
		clickLink("Administration"," ").link.click()
		
		when: "I want to configurate the SMTP"
		clickLink("System"," ").link.click()
		clickLink("Smtp Server Config"," ").link.click(NewUserPage)
		
		

		then: "The new user should be properly created"
		$().text().contains(" ")
		
		
		
	}
	
	
	
	

	
	
//	def cleanupSpec() {
//		server.stop()
//	}

}

//class SomePage extends Page {
//	def prop = 1
//}